import axios from 'axios';

// const baseUrl = 'http://59.110.166.140';

class HitTheListServer {
  request(opt = {}) {
    const params = {
      'headers': {
        'Content-Type': 'application/x-www-form-urlencoded',
      },
      'baseURL': 'http://59.110.166.140',
      'method': 'GET',
      'url': '',
      'data': {},
      ...opt,
    }
    return axios(params)
  }

  /**
   * 获取验证码
   * @param  {[type]} params [description]
   * @return {[type]}        [description]
   */
  getQrCode(params) {
    return this.request({
      url: `/vote/code`,
      params: params
    })
  }

  /**
   * 获取累计票数
   * @param  {[type]} params [description]
   * @return {[type]}        [description]
   */
  totalCount(params) {
    return this.request({
      url: `/vote/count`,
      params: params
    })
  }

  /**
   * 用户打卡接口
   * @param  {[type]} params [description]
   * @return {[type]}        [description]
   */
  meCell(params) {
    return this.request({
      url: `/vote/me/call`,
      params: params
    })
  }

  /**
   * 获取排行页面, 我的相关信息
   * @param  {[type]} params [description]
   * @return {[type]}        [description]
   */
  ladder(params) {
    return this.request({
      url: `/vote/ladder`,
      params: params
    })
  }

  meLadder(params) {
    return this.request({
      url: `/vote/me/ladder`,
      params: params
    })
  }

  /**
   * 获取当前用户打榜状态(对应 1. 为他打call 2.已打call)
   * @param  {[type]} params [description]
   * @return {[type]}        [description]
   */
  status(params) {
    return this.request({
      url: `/vote/me/status`,
      params: params
    })
  }

  count(params) {
    return this.request({
      url: `/vote/count`,
      params: params
    })
  }

  title(params) {
    return this.request({
      url: `/vote/title`,
      params: params
    })
  }
}

export default new HitTheListServer()